package com.tl.satoken.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tl.satoken.domain.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据heroId更新用户余额
     * 通过hero表关联到user表
     */
    @Update("UPDATE users u INNER JOIN hero h ON u.id = h.user_id SET u.balance = u.balance + #{coinCount} WHERE h.id = #{heroId}")
    int updateBalanceByHeroId(@Param("heroId") Integer heroId, @Param("coinCount") Integer coinCount);

}